﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Secondhand_Book_Trade
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                // 插入新用户
                int rows = SqlDataSource1.Insert();
                if (rows > 0)
                {
                    // 注册成功，跳转到登录页
                    Response.Write("<script>alert('注册成功！请登录');window.location='Login.aspx';</script>");
                }
                else
                {
                    Response.Write("<script>alert('注册失败，请重试');</script>");
                }
            }
            catch (Exception ex)
            {
                // 处理用户名重复等异常
                Response.Write("<script>alert('注册失败：" + ex.Message.Replace("'", "") + "');</script>");
            }
        }
    }
}